package offer.algorithm;


import java.util.Stack;

/**
 * Description：两个栈 实现 一个队列
 * Author: zhangc
 * Date：2017/7/18 16:23
 */
public class StackToQueue7<T> {

    private Stack<T> leftStack = new Stack<>();
    private Stack<T> rightStack = new Stack<>();

    private  int size =0 ;

    public void addTail(T val){
        leftStack.push(val);
        size++;
    }

    public T deleteHead(){
        if (rightStack.isEmpty()){
            if (leftStack.isEmpty())
                return null;
            else{
                while (!leftStack.isEmpty())
                    rightStack.push(leftStack.pop());
            }
        }
        size --;
        return rightStack.pop();
    }

    public boolean isEmpty(){
        return size > 0 ? false : true;
    }

}
